﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using SinsenWeb.Models;

namespace SinsenWeb.Helpers.Providers
{
    public class MemberUser : MembershipUser
    {
        public MemberUser(string providerName,
            string name,
            object providerUserKey,
            string email,
            string passwordQuestion,
            string comment,
            bool isApproved,
            bool isLockedOut,
            DateTime creationDate,
            DateTime lastLoginDate,
            DateTime lastActivityDate,
            DateTime lastPasswordChangedDate,
            DateTime lastLockoutDate,
            string firstname,
            string lastname)
            : base(providerName, name, providerUserKey, email, passwordQuestion, comment, isApproved, isLockedOut, creationDate, lastLoginDate, lastActivityDate, lastPasswordChangedDate, lastLockoutDate)
        {
            Firstname = firstname;
            Lastname = lastname;
        }

        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public string Fullname
        {
            get
            {
                return Firstname + " " + Lastname;
            }
        }

        public static MemberUser FromMember(Member member)
        {


            if (member == null)
                return null;

            var membershipUser = new MemberUser(typeof(SinsenMembershipProvider).Name,
                                                    member.Username,
                                                    member.Username,
                                                    member.Email,
                                                    string.Empty,
                                                    string.Empty,
                                                    true,
                                                    false,
                                                    DateTime.Now,
                                                    DateTime.Now,
                                                    DateTime.Now,
                                                    DateTime.Now,
                                                    DateTime.Now,
                                                    member.Firstname,
                                                    member.Lastname
                                                    );

            return membershipUser;

        }
    }
}
